dlnYn_def = [];
dlnYn_doubledef = [];
dlnYn_homog_def = [];
dlnYn_homog_doubledef = [];
gran_resn_def =[];
gran_resn_doubledef =[];
w_f =[];
dlnY_f = [];

for cty = {'AUS' 'AUT' 'BEL' 'BGR' 'BRA' 'CAN' 'CHN' 'CYP' 'CZE' ...
           'DEU' 'DNK' 'ESP'  'EST' 'FIN' 'GBR' ...
           'GRC' 'HUN' 'IDN' 'IND' 'IRL' 'ITA' 'JPN' 'KOR' ...
           'LTU' 'LVA' 'MEX' 'MLT' 'NLD' 'POL' 'PRT' 'ROU' 'RUS' ...
           'SVK' 'SVN' 'SWE' 'TUR' 'TWN'  'USA' };
    idx = find(ismember(ISO, cty));
    shockT = strcat(cty,'prod_p10');
    shockT=shockT{1};
    
    fn1 = strcat('MAT/rho',num2str(rhoT),'eta',num2str(etaT),'lambda',num2str(lambdaT),'_psi',num2str(varphi),'_sigma',num2str(sigmaT),'/Step_5_output_alpha',num2str(alphaT),...
          '_rho',rhoT,'_',shockT,'_approx.mat');
    load(fn1,'VA_fj_0','VA_hat_fj','RGDP_def_hat_n','GDP_deflator_n','RGDP_doubledef_hat_n','RGDP_doubledef_hat_fj');
          
    dlnYn_def = [dlnYn_def; (RGDP_def_hat_n(15)-1)];
    dlnYn_doubledef = [dlnYn_doubledef; (RGDP_doubledef_hat_n(15)-1)];
   
    aa = VA_fj_0/sum(VA_fj_0);
    w_f = [w_f aa];
    dlnY_f = [dlnY_f (RGDP_doubledef_hat_fj-1)*100];
    
    clear VA_fj_0 VA_hat_fj RGDP_doubledef_hat_fj RGDP_def_hat_n GDP_deflator_n RGDP_doubledef_hat_n
    
    % Homogeneous
     fn2 = strcat('MAT/rho',num2str(rhoT),'eta',num2str(etaT),'lambda',num2str(lambdaT),'_psi',num2str(varphi),'_sigma',num2str(sigmaT),'/Step_5_output_alpha',num2str(alphaT),...
           '_rho',rhoT,'_',shockT,'_Hom_approx.mat');
     load(fn2,'RGDP_def_hat_n','RGDP_doubledef_hat_n');   
        
     dlnYn_homog_def = [dlnYn_homog_def; (RGDP_def_hat_n(france)-1)];
     dlnYn_homog_doubledef = [dlnYn_homog_doubledef; (RGDP_doubledef_hat_n(france)-1)];
          
     clear RGDP_doubledef_hat_n RGDP_def_hat_n
     
     fn3 = strcat('MAT/rho',num2str(rhoT),'eta',num2str(etaT),'lambda',num2str(lambdaT),'_psi',num2str(varphi),'_sigma',num2str(sigmaT),'/Step_6_output_alpha',num2str(alphaT),...
          '_rho',rhoT,'_',shockT,'_approx.mat');
     load(fn3,'cov_e_f_def','cov_e_f_doubledef');
          
     gran_resn_def = [gran_resn_def; cov_e_f_def*.1];
     gran_resn_doubledef = [gran_resn_doubledef; cov_e_f_doubledef*.1];
end

ISO_lessFRA = {'', '', 'BEL', '', '', '', 'CHN' ,'', ...
           '', 'DEU', '', 'ESP' , '', '', 'GBR', ...
           '', '', '', '', '', 'ITA', 'JPN', '', ...
           '' ,'', '','', 'NLD', '', '', '','RUS', ...
           '', '', '', '', '', 'USA'};
   
labels = cellstr(ISO_lessFRA');
figure(5)
plot(dlnYn_doubledef.*100,gran_resn_doubledef.*100,'bo',dlnYn_doubledef.*100,dlnYn_doubledef.*100,'r-','LineWidth',2)
text(dlnYn_doubledef.*100,gran_resn_doubledef.*100,labels,'VerticalAlignment','bottom','HorizontalAlignment','right')
xlabel('$d\ln Y^m$','FontSize',16,'Interpreter','latex')
ylabel('$\Gamma^m$','FontSize',16,'Interpreter','latex')
fig5=strcat('Figures/rho',rhoT,'eta',etaT,'lambda',lambdaT,'_psi',num2str(varphi),'_sigma',num2str(sigmaT),'/Fig4a.eps');
saveas(gcf,fig5,'epsc2')

mean_dlnYn_doubledef = dlnYn_doubledef - gran_resn_doubledef;
figure(6)
plot(dlnYn_doubledef.*100,mean_dlnYn_doubledef.*100,'bo',dlnYn_doubledef.*100,dlnYn_doubledef.*100,'r-','LineWidth',2)
text(dlnYn_doubledef.*100,mean_dlnYn_doubledef.*100,labels,'VerticalAlignment','bottom','HorizontalAlignment','right')
xlabel('$d\ln Y^m$','FontSize',16,'Interpreter','latex')
ylabel('$\mathcal{E}^m$','FontSize',16,'Interpreter','latex')
fig6=strcat('Figures/rho',rhoT,'eta',etaT,'lambda',lambdaT,'_psi',num2str(varphi),'_sigma',num2str(sigmaT),'/Fig4b.eps');
saveas(gcf,fig6,'epsc2')